<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
</head>

<body>
    <div id="map">
    </div>
    <script>
        var map = new ol.Map({
            target: "map",
            layers: [gaode],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        /* 1、设置要素 geometry */
        /* 第一个参数和第二个参数 表示第一个点(左下角)
           第三个参数和第四个参数 表示第二个点(右上角)
         */
        var Rectangle = new ol.Feature({
            geometry: new ol.geom.Polygon.fromExtent([114.30, 30.50, 118, 34])
        });
        Rectangle.setStyle(new ol.style.Style({
            fill: new ol.style.Fill({
                color: 'rgba(33,33,33,0.5)'
            }),
            stroke: new ol.style.Stroke({
                color: '#ffcc33',
                width: 4
            })
        }));

        //实例化一个矢量图层Vector作为绘制层
        var source = new ol.source.Vector({
            features: [Rectangle]
        });
        //创建一个图层
        var vector = new ol.layer.Vector({
            source: source
        });
        //将绘制层添加到地图容器中
        map.addLayer(vector);
    </script>
</body>

</html>